package com.gaohe.official.controller;

import java.util.List;
import java.io.IOException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gaohe.common.log.annotation.Log;
import com.gaohe.common.log.enums.BusinessType;
import com.gaohe.common.security.annotation.RequiresPermissions;
import com.gaohe.official.domain.FmAttestation;
import com.gaohe.official.service.IFmAttestationService;
import com.gaohe.common.core.web.controller.BaseController;
import com.gaohe.common.core.web.domain.AjaxResult;
import com.gaohe.common.core.utils.poi.ExcelUtil;
import com.gaohe.common.core.web.page.TableDataInfo;

/**
 * 用户认证Controller
 * 
 * @author ruoyi
 * @date 2025-06-03
 */
@RestController
@RequestMapping("/attestation")
public class FmAttestationController extends BaseController
{
    @Autowired
    private IFmAttestationService fmAttestationService;

    /**
     * 查询用户认证列表
     */
    @RequiresPermissions("official:attestation:list")
    @GetMapping("/list")
    public TableDataInfo list(FmAttestation fmAttestation)
    {
        startPage();
        List<FmAttestation> list = fmAttestationService.selectFmAttestationList(fmAttestation);
        return getDataTable(list);
    }

    /**
     * 导出用户认证列表
     */
    @RequiresPermissions("official:attestation:export")
    @Log(title = "用户认证", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FmAttestation fmAttestation)
    {
        List<FmAttestation> list = fmAttestationService.selectFmAttestationList(fmAttestation);
        ExcelUtil<FmAttestation> util = new ExcelUtil<FmAttestation>(FmAttestation.class);
        util.exportExcel(response, list, "用户认证数据");
    }

    /**
     * 获取用户认证详细信息
     */
    @RequiresPermissions("official:attestation:query")
    @GetMapping(value = "/{attestationId}")
    public AjaxResult getInfo(@PathVariable("attestationId") Long attestationId)
    {
        return success(fmAttestationService.selectFmAttestationByAttestationId(attestationId));
    }

    /**
     * 新增用户认证
     */
    @RequiresPermissions("official:attestation:add")
    @Log(title = "用户认证", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FmAttestation fmAttestation)
    {
        return toAjax(fmAttestationService.insertFmAttestation(fmAttestation));
    }

    /**
     * 修改用户认证
     */
    @RequiresPermissions("official:attestation:edit")
    @Log(title = "用户认证", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FmAttestation fmAttestation)
    {
        return toAjax(fmAttestationService.updateFmAttestation(fmAttestation));
    }

    /**
     * 删除用户认证
     */
    @RequiresPermissions("official:attestation:remove")
    @Log(title = "用户认证", businessType = BusinessType.DELETE)
	@DeleteMapping("/{attestationIds}")
    public AjaxResult remove(@PathVariable Long[] attestationIds)
    {
        return toAjax(fmAttestationService.deleteFmAttestationByAttestationIds(attestationIds));
    }
}
